package com.quanshu.exchange.support.net.core;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

/**
 * 公共请求头拦截器
 */
public class HeaderInterceptor implements Interceptor {

    public HeaderInterceptor() {
    }

    /**
     * 给请求加上
     * @param chain
     * @return
     * @throws IOException
     */
    @Override
    public Response intercept(Chain chain) throws IOException {
        Request original = chain.request();
        Request request = original
                .newBuilder()
//                .header("User-Agent", cache.getUserName())
//                .header("Authorization", cache.getToken())
//                .header("os", "1")//0=苹果 1=安卓
//                .header("version", VersionUtil.getVersionName(MyApplication.getInstance()))
                .method(original.method(), original.body())
                .build();
        return chain.proceed(request);
    }
}
